package org.agile4j.patterns.proxy.order;

public class OrderProxy implements OrderApi {

	private Order order = null ;
	
	public OrderProxy(Order order){
		this.order = order ;
	}
	
	@Override
	public String getProductName() {
		return this.order.getProductName();
	}

	@Override
	public void setProductName(String productName, String user) {
		if (user != null && user.equals(this.getOrderUser())) {
			order.setProductName(productName, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public Integer getOrderNum() {
		return this.order.getOrderNum();
	}

	@Override
	public void setOrderNum(Integer orderNum, String user) {
		if(user != null && user.equals(this.order.getOrderUser())){
			this.order.setOrderNum(orderNum, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public String getOrderUser() {
		return this.order.getOrderUser();
	}

	@Override
	public void setOrderUser(String orderUser, String user) {
		if(user != null && user.equals(this.order.getOrderUser())){
			this.order.setOrderUser(orderUser, user);
		} else {
			System.out.println(user + "用户没有权限.");
		}
	}

	@Override
	public String toString() {
		return "OrderProxy [getProductName()=" + getProductName() + ", getOrderNum()=" + getOrderNum() + ", getOrderUser()=" + getOrderUser() + "]";
	}
	
}
